//没有重复的数据 
const arr = ["red"," green", "red"];
const set = new Set(arr);
console.log(set);

const user = {
    name: "张三",
    age : 20,

};
console.log(Object.keys(user));
console.log(Object.values(user));

//把一个对象转化为一个数组 
console.log(Object.entries(user));  //[ [ 'name', '张三' ], [ 'age', 20 ] ]

const arrData = [
  ["name", "张三"],
  ["age", 20],
];
const objData = Object.fromEntries(arrData);
console.log(objData);


//序列化
const strJson = JSON.stringify(user);
console.log(strJson);

//反序列化
const objJson = JSON.parse(strJson);
console.log(objJson);



//----------结构赋值---------
const user1 = {
  name: "张三",
  age : 20,

};

let {name ,age } = user; //和下面的相同 
//let {name, age} =  {name: "张三",age : 20,};
console.log(name);
console.log(age);

//数组的结构赋值
const arr1 = ["red", "green", "blue"];
const [RED, GREEN, BLUE] = arr;

function f1(title ="标题",width = 200, height = 100){
  console.log(`${title}:${width}:${height}`);
}
f1("hello",undefined, 200);

//函数调用,实参的值赋给形参变量 
function f2({title ="标题",width = 200, height = 100}){
  console.log(`${title}:${width}:${height}`);
}
f2({title :"标题",width : 200});